<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include page="header.jsp"></jsp:include>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<div style="min-height: 75px">
    <div class="achat">
        <form action="AjoutSyllabusSyllatheque" method="post" onsubmit="return validerFormAchat()" name="formAchat">
            <strong><fmt:message key="quantity" /> : </strong><br />
            <input type="number" name="quantite" id="quantite" size="5" value="1" min="1" max="999" />
            <br />
            <span style="float: right;">
                <input type="hidden" name="prix" value="${prixTotal}" />
                <input type="hidden" name="idSyllabus" value="${syllabus.syllabusId}" /><br />                
                <input type="submit" class="btn primary" value="<fmt:message key="btnAdd" />" />
            </span>
        </form>
                <span class="prixAchat" id="prixTotalAchat">
                    <c:if test="${sessionScope['usr'] == null}">${prixTotal} €</c:if>
                    <c:if test="${sessionScope['usr'].isProf == false}">${prixTotal} €</c:if>
                    <c:if test="${sessionScope['usr'].isProf == true}">${prixTotal} €<br />
                        <span class="ancienPrix">${prixTotalAncien} €</span>
                    </c:if>
                </span>
    </div>
    <div style="margin-top: 15px;"><fmt:message key="infoVente" /></div>
</div>

<div class="ecartSyllabus">
    <div class="imageSyllabus">
        <img src="tp/images/syllabus.png" alt="" />
    </div>
    <div class="blocSyllabus">
        <h3>${syllabus.libelle}</h3>
        <span class="descriptionSyllabus">
            ${syllabus.description}<br />
            <fmt:message key="author" /> <strong>${syllabus.auteur.nom} ${syllabus.auteur.prenom}</strong>.
        </span>
        
        <hr class="hrSyllabus" />
        
        <label for="langue" style="margin-top: 3px"><strong><fmt:message key="langue" /> : </strong></label><br />
        <strong>${syllabus.langue}</strong>
        <br />
        <label for="prix" style="margin-top: 3px"><strong><fmt:message key="nbElementVente" /> : </strong></label><br />
        <strong>${syllabus.nbPage}</strong>
        <br />
        
        <div class="reduction">
            <c:if test="${isReduction == true}">
                <span class="splash">
                    <img src="tp/images/splash.png" alt="<fmt:message key="soumis" />" 
                         title="<fmt:message key="soumis" />" />
                </span>
            </c:if>
            <label for="prix" style="margin-top: 3px"><strong><fmt:message key="prixVente" /> : </strong></label><br />
            <strong>${syllabus.prix} €</strong>
            <c:if test="${isReduction == true}">
                <br />
                <label for="prix" style="margin-top: 3px"><strong><fmt:message key="reduc" /> : </strong></label><br />
                <span class="red">${syllabus.reduction.reduction} %</span>
                <br />
                <label for="prix" style="margin-top: 3px"><strong><fmt:message key="endReduc" /> : </strong></label><br />     
                ${syllabus.reduction.getDateFinString()}                
            </c:if>
        </div>
        
        <h4 class="h4Ecart"><fmt:message key="MotsClef" /></h4>
        <c:if test="${syllabus.motsClefs != null}">
            <c:forEach var="c" items="${syllabus.motsClefs}" >
                <span class="motsClefs">${c}</span>
            </c:forEach>
        </c:if>
        
        <h4 class="h4Ecart"><fmt:message key="catVente" /></h4>
        <span class="categorie"><a href="CategorieSyllatheque?id=${syllabus.categorie.codeId}">${syllabus.categorie.denomination}</a></span>
        
    </div>
</div>

<script type="text/javascript">
    var quantite = document.getElementById('quantite'),
    prixForm = document.getElementById('prixTotalAchatHidden'),
    prix = ${prixTotal};
    quantite.onchange = function(){
        document.getElementById('prixTotalAchat').innerHTML = parseInt(quantite.value, 10) * prix + " \u20ac";
        prixForm.value = parseInt(quantite.value, 10) * prix;
    }
</script>
<script type="text/javascript" src="tp/js/function.js"></script>
           
<jsp:include page="footer.jsp"></jsp:include>